#include<iostream>
#include<vector>
using namespace std;


class Solution {
public:
    int areaOfMaxDiagonal(vector<vector<int>>& dimensions) {
        long long maxline2 = 0; int maxdimen = 0;
        int n = dimensions.size();
        int maxa = 0; int maxb = 0;
        for (int i = 0; i < n; i++) {
            int tmpa = dimensions[i][0];
            int tmpb = dimensions[i][1];
            long long tmpline2 = tmpa * tmpa + tmpb * tmpb;
            if (tmpline2 > maxline2) {
                maxa = tmpa; maxb = tmpb;
                maxline2 = tmpline2;
                maxdimen = maxa * maxb;
            }
            else if (tmpline2 == maxline2) {
                if (maxa * maxb < tmpa * tmpb) {
                    maxa = tmpa;
                    maxb = tmpb;
                    maxdimen = maxa * maxb;
                }
            }
        }
        return maxdimen;
    }
};